import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import*
from selenium.webdriver.support.select import Select
testCase="DBshop006_删除订单"
dr=openBrowser(urlAdmin)
DBshopLoginAdmin(dr)
# 1.点击销售管理订单管理界面。
DBshopEnterMenu2(dr,"销售管理","订单管理")
s=dr.find_element_by_xpath("//body").text
l="订单数\："
r="\)"
num1=reGetString(s,l,r)
# 2.在订单号查询框输入orderID，点击“搜索”按钮。
rootPath=get_pro_rootpath()
orderNo=readFile(rootPath+'\public\orderID.txt')
DBshopSearchOrderID(dr,orderNo)
# 3.勾选，点击删除
dr.find_element_by_xpath('//*[@id="select_checkbox_state_1"]').click()
s=Select(dr.find_element_by_xpath('//*[@id="allEdit"]'))
s.select_by_visible_text('删除')
dr.find_element_by_xpath('/html/body/div[2]/div/div[2]/table/tbody/tr[3]/td/div[1]/button').click()
dr.switch_to.alert.accept()
time.sleep(1)
#删除前的订单数=删除后的订单数+1
s=dr.find_element_by_xpath("//body").text
num2=reGetString(s,l,r)
if int(num1)==int(num2)+1:
    writeLog("%s 测试通过" % (testCase))
else:
    writeLog("%s 测试失败" % (testCase))
    getPhoto(dr)
dr.quit()